#ifndef LONGKEY_THREAD_POOL_CALLBACK_H_
#define LONGKEY_THREAD_POOL_CALLBACK_H_

template <typename T>
class ThreadPoolCallBack0 : public UserWorkItem
{
public:
	explicit ThreadPoolCallBack0(T* obj, void (T::*fun)())
		: obj_(obj), fun_(fun) { }

private:
	virtual void DoProcess()
	{
		(obj_->*fun_)();
	}
	T* obj_;
	void (T::*fun_)();

	DISALLOW_COPY_AND_ASSIGN(ThreadPoolCallBack0);
};

template <typename T, typename P1>
class ThreadPoolCallBack1 : public UserWorkItem
{
public:
	explicit ThreadPoolCallBack1(T* obj, void (T::*fun)(P1), P1 p1)
		: obj_(obj), fun_(fun), p1_(p1) {}
private:
	virtual void DoProcess()
	{
		(obj_->*fun_)(p1_);
	}

	T* obj_;
	void (T::*fun_)(P1);
	P1 p1_;

	DISALLOW_COPY_AND_ASSIGN(ThreadPoolCallBack1);
};

template <typename T, typename P1, typename P2>
class ThreadPoolCallBack2 : public UserWorkItem
{
public:
	explicit ThreadPoolCallBack2(T* obj, void (T::*fun)(P1, P2), P1 p1, P2 p2)
		: obj_(obj), fun_(fun), p1_(p1), p2_(p2) {}
private:
	virtual void DoProcess()
	{
		(obj_->*fun_)(p1_, p2_);
	}
	T* obj_;
	void (T::*fun_)(P1, P2);
	P1 p1_;
	P2 p2_;

	DISALLOW_COPY_AND_ASSIGN(ThreadPoolCallBack2);
};

#endif